主机选择
Ubuntu 14.04 LTS
登录主机
ssh root@xx.xx.xx.xx
操作系统升级
apt-get update
操作系统升级apt-get upgrade
软件升级apt-get autoremove
删除升级包
设置主机时区
dpkg-reconfigure tzdata
设置主机名
vim /etc/hosts
xx.xx.xx.xx hostname.example.com hostnamevim /etc/hostmane
hostname.example.comhostname -F /etc/hostname
更新主机名
绑定域名
**
创建新的主机用户
adduser username
usermod -a -G sudo username
logout
安装Nginx
sudo add-apt-repository ppa:rtcamp/nginx -y
sudo apt-get update
sudo apt-get install nginx-custom -y
至此可以尝试打开下网站看看
配置Nginx(1/3)
vim /etc/nginx/nginx.conf
user www-data; www-data 修改为主机登录用户名
worker_processes 4; _进程数
client_max_body_size 8m; _ 增加设置上传文件大小
sudo nginx -t
检测配置信息准确性sudo service nginx restart
重启Nginx服务器
创建虚拟目录
在用户根目录下创建同名站点文件夹mkdir ~/example.com
mkdir ~/example.com/logs
mkdir ~/example.com/public
配置Nginx(2/3)
../nginx/sites-available目录创建同名服务器配置信息cd /etc/nginx/sites-available
sudo vim example.com
加入server配置信息,尤其是路径信息;配置信息如下:
server {
server_name example.com www.example.com;
access_log /home/daodao/example.com/logs/access.log;
error_log /home/daodao/example.com/logs/error.log;
root /home/daodao/example.com/public/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
建立软连接../sites-available和../sites-enabled,类似于快捷键方式关联sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
配置Nginx(3/3)
sudo nginx -t
sudo service nginx restart
安装PHP
sudo apt-get install php5-fpm php5-common php5-mysqlnd php5-xmlrpc php5-curl php5-gd php5-imagick php5-cli php-pear php5-dev php5-imap php5-mcrypt
配置PHP
vim /etc/php5/fpm/pool.d/www.conf
user = www-data // 将www-data修改为登录名
group = www-data
listen.owner = www-data
listen.group = www-data
vim /etc/php5/fpm/php.ini
post_max_size = 8M
upload_max_filesize = 8M
sudo php5-fpm -t
安装MySQL
sudo apt-get install mysql-server
sudo mysql_install_db
sudo mysql_secure_installation
创建MySQL数据库
mysql -u root -p
> CREATE DATABASE example_com;
> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
> GRANT ALL PRIVILEGES ON example_com.* TO ‘username'@'localhost';
> GRANT SELECT, INSERT, UPDATE, DELETE ON example_com.* TO 'username'@'localhost';
> FLUSH PRIVILEGES;
> exit;
安装wordpress
...
参考阅读
https://deliciousbrains.com/hosting-wordpress-setup-secure-virtual-server/
http://www.cszhi.com/20120513/nginx| d2fd74eb2614cbbab80c956c8ba6cfe632 |nginx-conf.html
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。